package com.wms.controller;

import com.wms.dto.GoodsInPageQueryDTO;
import com.wms.dto.StoragePageQueryDTO;
import com.wms.entity.WmsGoodsin;
import com.wms.result.PageResult;
import com.wms.result.Result;
import com.wms.service.GoodsInService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/goodsin")
@Slf4j
@Api(tags = "物品入库模块")
public class GoodsInController {
    @Autowired
    private GoodsInService goodsInService;

    /**
     * 入库分页查询
     * @param goodsInPageQueryDTO
     * @return
     */
    @PostMapping("/page")
    @ApiOperation("分页查询")
    public Result<PageResult> page(@RequestBody GoodsInPageQueryDTO goodsInPageQueryDTO){
        PageResult pageResult = goodsInService.page(goodsInPageQueryDTO);
        return Result.success(pageResult);
    }

    /**
     * 批量删除入库
     * @param ids
     * @return
     */
    @DeleteMapping("/delete")
    @ApiOperation("批量删除入库")
    public Result delete(@RequestParam List<Integer> ids){
        goodsInService.delete(ids);
        return Result.success();
    }

    /**
     * 申请入库
     * @return
     */
    @PostMapping("/applyin")
    @ApiOperation("申请入库")
    public Result applyIn(@RequestBody WmsGoodsin wmsGoodsin){
        goodsInService.applyIn(wmsGoodsin);
        return Result.success();
    }

    /**
     * 通过审核
     * @param id
     * @return
     */
    @PostMapping("/applypass/{id}")
    @ApiOperation("入库审核")
    public Result applyPass(@PathVariable int id){
        log.info("审核申请,参数为:{}",id);
        goodsInService.applyPass(id);
        return Result.success();
    }

    /**
     * 不通过
     * @param id
     * @return
     */
    @PostMapping("/applyfail/{id}")
    @ApiOperation("入库审核不通过")
    public Result applyFail(@PathVariable int id){
        log.info("审核申请,参数为:{}",id);
        goodsInService.applyFail(id);
        return Result.success();
    }
}
